<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@include file="/WEB-INF/public/head.jsp" %>


<%@include file="/WEB-INF/public/nav.jsp" %>
<style>
    .row .cf{
        margin-bottom: 10px;
    }
</style>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>


        <%@include file="/WEB-INF/public/menu.jsp" %>

        <div class="main-content">
            <%@include file="/WEB-INF/public/breadcrumb.jsp" %>

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" id="form">
                            <c:forEach items="${sysSettings}" var="s">
                            <div class="form-group">
                                <label class="col-sm-4 control-label no-padding-right"> ${s.name} </label>
                                <div class="col-sm-8">
                                    <c:choose>
                                        <c:when test="${s.k == 'description' || s.k=='footer'}">
                                            <textarea name="v" id="v" cols="30" rows="10">${s.v}</textarea>
                                        </c:when>
                                        <c:otherwise>
                                            <input type="text" name="v" id="v" placeholder="变量说明" class="col-xs-10 col-sm-5" value="${s.v}">
                                        </c:otherwise>
                                    </c:choose>
                                    <input type="hidden" name="k" value="${s.k}"/>
                                    <input type="hidden" name="name" value="${s.name}">
                                    <%--<input type="hidden" name="type" value="0">--%>
                                </div>
                            </div>
                            </c:forEach>

                            <div class="col-md-offset-4 col-md-6">
                                <button id="btnSubmit" class="btn btn-info submit" type="button">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->

    </div><!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- /.main-container -->
<%@include file="/WEB-INF/public/footerjs.jsp" %>
<script src="/js/ittaoli.js"></script>
<script src="/ace/js/bootbox.min.js"></script>
<script>
    $('#btnSubmit').click(function(){
        var form=ittaoli.serializeObject($('#form'));
//        console.log(form);
        var vArr=form.v.split(',');
        var kArr=form.k.split(',');
        var nameArr=form.name.split(',');
//        var typeArr=form.type.split(',');
        var obj=[];
        vArr.forEach(function(item,index){
            obj.push({v:item,k:kArr[index],name:nameArr[index]});
        });
//        console.log(obj);
        $.post("/setting/doEditSysConfig",{obj:JSON.stringify(obj)},function(data){
            console.log(data);
            if(data>0){
                bootbox.alert("更新成功");
            }
            else{
                bootbox.alert("更新失败");
            }
        })
    })
</script>
<%@include file="/WEB-INF/public/foot.jsp" %>
